package test;

import bean.Emp;
import dao.EmpDao;
import dao.impl.EmpDaoImpl;
import org.junit.Test;
import utils.DruidUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo {
    @Test //测试方法
    public void test(){
        Connection con = DruidUtils.getConnection();
        System.out.println(con);
        Statement sta = null;
        try {
            sta = con.createStatement();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        DruidUtils.close(con,sta);
    }
    @Test //dao实现类方法测试
    public void testM(){
        EmpDao e = new EmpDaoImpl();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date parse = sdf.parse("1998-02-02");
            Emp test = new Emp(8000,"UPDATE","CLERK",8888,parse,6000.00,1000.00,40);
            e.update(8000,test);
        } catch (ParseException ex) {
            throw new RuntimeException(ex);
        }
    }
}
